/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// Generated by tools/resource-gen
// Run "make generate" to update this file.

// nolint:whitespace
package v1alpha1

import (
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

	systemproto "github.com/apache/dubbo-admin/api/system/v1alpha1"
	coremodel "github.com/apache/dubbo-admin/pkg/core/resource/model"
)

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories=dubbo,scope=Cluster

const ZoneInsightKind = "ZoneInsight"

type ZoneInsightResource struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	// Mesh is the name of the dubbo mesh this resource belongs to.
	// It may be omitted for cluster-scoped resources.
	//
	// +kubebuilder:validation:Optional
	Mesh string `json:"mesh,omitempty"`
	// Spec is the specification of the Dubbo ZoneInsight resource.
	// +kubebuilder:validation:Optional
	Spec *systemproto.ZoneInsight `json:"spec,omitempty"`
	// Status is the status of the Dubbo ZoneInsight resource.
	Status ZoneInsightResourceStatus `json:"status,omitempty"`
}

type ZoneInsightResourceStatus struct {
	// define resource-specific status here
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Namespaced
type ZoneInsightResourceList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []ZoneInsightResource `json:"items"`
}

func (r *ZoneInsightResource) GetKind() string {
	return r.Kind
}

func (r *ZoneInsightResource) GetMesh() string {
	return r.Mesh
}

func (r *ZoneInsightResource) SetMesh(mesh string) {
	r.Mesh = mesh
}

func (r *ZoneInsightResource) GetResourceKey() string {
	return coremodel.BuildResourceKey(r.Mesh, r.Kind, r.Name)
}

func (r *ZoneInsightResource) GetMeta() metav1.ObjectMeta {
	return r.ObjectMeta
}

func (r *ZoneInsightResource) SetMeta(m metav1.ObjectMeta) {
	r.ObjectMeta = m
}

func (r *ZoneInsightResource) GetSpec() coremodel.ResourceSpec {
	return r.Spec
}

func (r *ZoneInsightResource) SetSpec(rs coremodel.ResourceSpec) error {
	if spec, ok := rs.(*systemproto.ZoneInsight); ok {
		r.Spec = spec
		return nil
	}
	return coremodel.ErrorInvalidItemType(r.Spec, rs)
}
